
#include <mockcpp/mockcpp.hpp>
#include <testngpp/testngpp.hpp>
#include <Rectangle.h>

USING_MOCKCPP_NS
USING_TESTNGPP_NS

FIXTURE(Rectangle)
{
	TEST(perimeter should 8 with length 2 and width 2)
	{
		Rectangle  rectangle(2, 2);
		ASSERT_EQ(8,rectangle.getPerimeter());
	}

        TEST(perimeter should 10 with length 2 and width 3)
        {
                Rectangle  rectangle(2, 3);
                ASSERT_EQ(10,rectangle.getPerimeter());
        }

        TEST(area should 4 with length 2 and width 2)
        {
                Rectangle  rectangle(2, 2);
                ASSERT_EQ(4,rectangle.getArea());
        }

        TEST(area should 6 with length 2 and width 3)
        {
                Rectangle  rectangle(2, 3);
                ASSERT_EQ(6,rectangle.getArea());
        }

	TEST(perimeter should be 0 if length is 0)
	{
		Rectangle rectangle(0, 10);
		ASSERT_EQ(0, rectangle.getPerimeter());
	}

	TEST(area should be 0 if length is 0)
	{
		Rectangle rectangle(0, 10);
		ASSERT_EQ(0, rectangle.getArea());
	}

	TEST(perimeter should be 0 if length is 100.01)
	{
		Rectangle rectangle(100.01, 10);
		ASSERT_EQ(0, rectangle.getPerimeter());
	}

	TEST(area should be 0 if length is 100.01)
	{
		Rectangle rectangle(100.01, 10);
		ASSERT_EQ(0, rectangle.getArea());
	}

	TEST(perimeter should be 220 if length 100.001 and width 10)
	{
		Rectangle rectangle(100.001, 10);
		ASSERT_EQ(220, rectangle.getPerimeter());
	}

	TEST(area should be 1000 if length 100.001 and width 10)
	{
		Rectangle rectangle(100.001, 10);
		ASSERT_EQ(1000, rectangle.getArea());
	}

	TEST(perimeter should be 0 if width is 0)
	{
		Rectangle rectangle(10, 0);
		ASSERT_EQ(0, rectangle.getPerimeter());
	}

	TEST(area should be 0 if width is 0)
	{
		Rectangle rectangle(10, 0);
		ASSERT_EQ(0, rectangle.getArea());
	}

	TEST(perimeter should be 0 if width is 75)
	{
		Rectangle rectangle(10, 75);
		ASSERT_EQ(0, rectangle.getPerimeter());
	}

	TEST(area should be 0 if width is 75.001)
	{
		Rectangle rectangle(10, 75.001);
		ASSERT_EQ(0, rectangle.getPerimeter());
	}

	TEST(perimeter should be 348 if length 100 and width 74.001)
	{
		Rectangle rectangle(100, 74.001);
		ASSERT_EQ(348, rectangle.getPerimeter());
	}

	TEST(area should be 1000 if length 100 and width 74.001)
	{
		Rectangle rectangle(100, 74.001);
		ASSERT_EQ(7400, rectangle.getArea());
	}

	TEST(perimeter should be 120.2 if length / width are 10.055, 50.055)
	{
		Rectangle rectangle(10.055, 50.055);
		ASSERT_TRUE(0.00001>(rectangle.getPerimeter()-120.2));
	}

	TEST(area should be 503 if length / width are 10.055, 50.055)
	{
		Rectangle rectangle(10.055, 50.055);
		ASSERT_TRUE(0.00001>(rectangle.getArea()-503));
	}

	TEST(perimeter should be 120.32 if length / width are 10.085, 50.085)
	{
		Rectangle rectangle(10.085, 50.085);
		ASSERT_TRUE(0.00001>(rectangle.getPerimeter()-120.32));
	}
	
	TEST(area should be 504.81 if length / width are 10.085, 50.085)
	{
		Rectangle rectangle(10.085, 50.085);
		ASSERT_TRUE(0.00001>(rectangle.getArea()-504.81));
	}

	TEST(set length from 10.055 to 80, width keep no change as 50.055, perimeter should be (80+50.05)*2=260.1)
	{
		Rectangle rectangle(10.055, 50.055);
		rectangle.setProperty(80, 50.055);
		ASSERT_TRUE(0.00001>(rectangle.getPerimeter()-260.1));
	}

	TEST(set length from 10.055 to 80, width keep no change as 50.055, area should be 80*50.05=4004)
	{
		Rectangle rectangle(10.055, 50.055);
		rectangle.setProperty(80, 50.055);
		ASSERT_EQ(4004, rectangle.getArea());
	}

	TEST(set length from 10.055 to 0, width keep no change as 50.055, perimeter should be 0)
	{
		Rectangle rectangle(10.055, 50.055);
		rectangle.setProperty(0, 50.055);
		ASSERT_EQ(0, rectangle.getPerimeter());
	}

	TEST(set length from 10.055 to 0, width keep no change as 50.055, area should be 0)
	{
		Rectangle rectangle(10.055, 50.055);
		rectangle.setProperty(0, 50.055);
		ASSERT_EQ(0, rectangle.getArea());
	}

	TEST(set width from 50.055 to 20, length keep no change as 80.055, perimeter should be (80.05+20)*2=200.1)
	{
		Rectangle rectangle(80.055, 50.055);
		rectangle.setProperty(80.055, 20);
		ASSERT_EQ(0, rectangle.getPerimeter()-200.1);
	}

	TEST(set width from 50.055 to 20, length keep no change as 80.055, area should be 80.05*20=1601)
	{
		Rectangle rectangle(80.055, 50.055);
		rectangle.setProperty(80.055, 20);
		ASSERT_EQ(1601, rectangle.getArea());
	}

	TEST(set width from 50.055 to 0, width keep no change as 80.055, perimeter should be 0)
	{
		Rectangle rectangle(80.055, 50.055);
		rectangle.setProperty(80.055, 0);
		ASSERT_EQ(0, rectangle.getPerimeter());
	}

	TEST(set width from 50.055 to 0, width keep no change as 80.055, area should be 0)
	{
		Rectangle rectangle(80.055, 50.055);
		rectangle.setProperty(80.055, 0);
		ASSERT_EQ(0, rectangle.getArea());
	}

	TEST(perimeter of square should be 200 when side length is 50)
	{
		Rectangle rectangle(50);
		ASSERT_EQ(200, rectangle.getPerimeter());
	}

	TEST(area of square should be 2500 when side length is 50)
	{
		Rectangle rectangle(50);
		ASSERT_EQ(2500, rectangle.getArea());
	}

	TEST(perimeter of square should be 0 when side length is 0)
	{
		Rectangle rectangle(0);
		ASSERT_EQ(0, rectangle.getPerimeter());
	}

	TEST(area of square should be 0 when side length is 0)
	{
		Rectangle rectangle(0);
		ASSERT_EQ(0, rectangle.getArea());
	}

	TEST(perimeter of square should be 0 when side length is 75)
	{
		Rectangle rectangle(75);
		ASSERT_EQ(0, rectangle.getPerimeter());
	}

	TEST(area of square should be 0 when side length is 75)
	{
		Rectangle rectangle(75);
		ASSERT_EQ(0, rectangle.getArea());
	}

	TEST(when side length is 50.055, perimeter of square should be 50.05*4=200.2)
	{
		Rectangle rectangle(50.055);
		ASSERT_EQ(0, rectangle.getPerimeter()-200.2);
	}

	TEST(when side length is 50.055, area of square should be 50.05*50.05=2505.0025=2505.00)
	{
		Rectangle rectangle(50.055);
		ASSERT_EQ(2505, rectangle.getArea());
	}

	TEST(when side length is 50.085, perimeter of square should be 50.08*4=200.32)
	{
		Rectangle rectangle(50.085);
		ASSERT_EQ(0, rectangle.getPerimeter()-200.32);
	}

	TEST(when side length is 50.085, area of square should be 50.08*50.08=2508.0064=2508.01)
	{
		Rectangle rectangle(50.085);
		ASSERT_TRUE(0.00001>(rectangle.getArea()-2508.01));
	}

	TEST(change side length from 50 to 25, perimeter of square should be 100)
	{
		Rectangle rectangle(50);
		rectangle.setProperty(25);
		ASSERT_EQ(100, rectangle.getPerimeter());
	}

	TEST(change side length from 50 to 25, area of square should be 625)
	{
		Rectangle rectangle(50);
		rectangle.setProperty(25);
		ASSERT_EQ(625, rectangle.getArea());
	}

	TEST(change side length from 50 to 75, perimeter of square should be 0)
	{
		Rectangle rectangle(50);
		rectangle.setProperty(75);
		ASSERT_EQ(0, rectangle.getPerimeter());
	}

	TEST(change side length from 50 to 75, area of square should be 0)
	{
		Rectangle rectangle(50);
		rectangle.setProperty(75);
		ASSERT_EQ(0, rectangle.getArea());
	}

};
